<?php

namespace App\Admin\Controllers\setting;

use App\Admin\Repositories\setting\CmcSystemCity;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class CmcSystemCityController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new CmcSystemCity(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('city_id');
            $grid->column('level');
            $grid->column('parent_id');
            $grid->column('area_code');
            $grid->column('name');
            $grid->column('merger_name');
            $grid->column('lng');
            $grid->column('lat');
            $grid->column('is_show')->switch()->filter(
                Grid\Column\Filter\In::make([
                    0 => '不显示',
                    1 => '显示',
                ])
            );;

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new CmcSystemCity(), function (Show $show) {
            $show->field('id');
            $show->field('city_id');
            $show->field('level');
            $show->field('parent_id');
            $show->field('area_code');
            $show->field('name');
            $show->field('merger_name');
            $show->field('lng');
            $show->field('lat');
            $show->field('is_show');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new CmcSystemCity(), function (Form $form) {
            $form->display('id');
            $form->text('city_id');
            $form->text('level');
            $form->text('parent_id');
            $form->text('area_code');
            $form->text('name');
            $form->text('merger_name');
            $form->text('lng');
            $form->text('lat');
            $form->switch('is_show');
        });
    }

}
